<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>黑名单管理</title>
    <link href="../../layui/css/layui.css" rel="stylesheet" type="text/css">
    <link href="../../css/style.css" rel="stylesheet" type="text/css">
    <script src="../../layui/layui.js"></script>
    <script src="../../js/jquery-1.8.3.js"></script>
    <script src="../../js/util.js"></script>
    <script>
    
        layui.use(['table', 'form', 'jquery','element'], function () {
            var table = layui.table;
            var form = layui.form;
            var $ = layui.$;
            var tabledata = {
                elem: "#table",//表格id
                id: "modelReload", //id
                url: '/xuYiBlackUser/find',
                method: 'post',
                request: {
                    pageName: 'page',
                    limitName: 'limit'
                },
                response: {
                    statusName: 'code',
                    statusCode: 0,
                    msgName: 'msg',
                    countName: 'count',
                    dataName: 'data'
                },
                page: true,
                count: "count",
                limit: 10,
                limits: [10, 20, 30, 40, 50],
                layout: ['prev', 'page', 'next'],
                prev: "上一页",
                next: "下一页",
                cols: [[ //表头
                    {field: 'phoneNumber', title: '手机号码',align:'center'}
                    , {field: 'createTime', title: '录入时间',align:'center'}
                    , {field: 'operation', title: '操作',align:'center', toolbar: '#barDemo'}
                ]]
            };
            table.render(tabledata);
            table.on('tool(demo)', function (obj) {
                var data = obj.data;
                if (obj.event === 'del') {
                    layer.confirm('您确定要删除吗', {icon: 3, title: '提示'}, function (index) {
                        var url = "/xuYiBlackUser/delete";
                        var param = {
                            phoneNumber: data.phoneNumber
                        };
                        $.ajax({
                            type: 'post',
                            data: param,
                            url: url,
                            beforeSend: function () {
                            },
                            success: function (data) {
                                layui.use('layer', function () {
                                    if (data == 1) {
                                        layer.confirm('删除成功', {
                                            btn: ['确认'] //按钮
                                        }, function(){
                                            location.href = "xuYiBlackUserManage.html";
                                        });
                                    }
                                    else {
                                        layer.confirm('删除失败，请重试', {
                                            btn: ['确认'] //按钮
                                        }, function(){
                                            location.href = "xuYiBlackUserManage.html";
                                        });
                                    }
                                });
                            },
                            complete: function () {

                            },
                            error: function (data) {
                                layer.msg('系统异常，请联系管理员处理!');
                            }
                        });
                    });

                }
            });

            $('#find').on('click', function () {
                // console.log(document.getElementById("mgrName").value)
                var phoneNumber = $("#phoneNumber").val();
                if(isNull(phoneNumber)){
                    layer.msg("请先输入手机号码进行查询");
                    return false;
                }else{
                    if (testMsisdn(phoneNumber)) {
                        layer.msg("手机号格式有误");
                        return false;
                    }
                    table.reload('modelReload', {
                        method: 'post',
                        page: {
                            curr: 1
                        },
                        where: {
                            phoneNumber:phoneNumber
                        }
                    });
                }


            });
        });

    </script>
    <script type="text/html" id="barDemo">
        <a href="#" lay-event="del">删除</a>
    </script>
</head>
<body>
<div class="layui-content-body">
    <div class="scroll-box">
        <div class="breadcrumb-box">
              <span class="layui-breadcrumb" lay-separator="|">
                <a href="javascript:returnIndex2()">首页&nbsp;</a>
                <a href=""> &nbsp;黑名单管理</a>
              </span>
        </div>
        <div class="content-box">
            <div class="form-select-box">
                <div class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label" >手机号码</label>
                            <div class="layui-input-block">
                                <input type="text" name="phoneNumber" lay-verify="required" value=""
                                       autocomplete="off" class="layui-input" id="phoneNumber">
                            </div>
                        </div>
                        <div class="layui-inline" pane="">
                            <button class="layui-btn layui-btn-normal" id="find">查询</button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="table-box">
                <table class="layui-table" id="table" lay-filter="demo">
                </table>
            </div>
        </div>
    </div>
</div>
</body>
</html>